package com.willen.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.willen.entity.Admin;
import com.willen.util.DBHelp;
import com.willen.util.RowMapper;

public class AdminDao {
	DBHelp<Admin> db=new DBHelp<Admin>();
	public List<Admin> fingByUserName(String username){
		String sql="select id,username,password,email,ip,role,lastaccesstime,createtime from t_admin where username=?";
		return db.executeForList(sql, new Mapper(), username);
	}
	private class Mapper implements RowMapper<Admin>{

		public Admin add(ResultSet rs) throws SQLException {
			Admin admin=new Admin();
			admin.setId(rs.getString("id"));
			admin.setUsername(rs.getString("username"));
			admin.setPassword(rs.getString("password"));
			admin.setEmail(rs.getString("email"));
			admin.setIp(rs.getString("ip"));
			admin.setRole(rs.getString("role"));
			admin.setLastaccesstime(rs.getString("lastaccesstime"));
			return admin;
		}}
}
